<?php $this->set('title', 'Surveys'); ?>
<?php $this->set('external_css', array('surveys.css')); ?>
<?php $session->flash();?>
<!-- Survey Results Links -->
<b>Survey Results</b><br />
<?php echo $html->link("Individual", array('controller' => 'presenters', 'action' => 'search_audience')); ?> | 
<?php echo $html->link("Group", array('controller' => 'presenters', 'action' => 'group_results')); ?>
<div class="header">My Surveys</div>
<br />
<span style="font-size:18px;font-weight:bold;">Search Surveys</span>&nbsp;&nbsp;
<?php echo $html->link("Show All",
		  array('controller' => 'surveys', 'action' => 'show_all')); ?>
		  
<!-- Presenter Search -->
<?php echo $this->element('presenter_search',
				array("controller" => "Surveys", "action" => "index"));?>

<?php echo $html->link(($html->image("icons/add.png")." Add New Survey"),
 			array('controller' => 'surveys', 'action' => 'add'),
			array('escape' => false)); ?>
			
<?php if($display) { ?>	
<table style="" cellpadding="5" cellspacing="0" border="0">
	<tr>
		<td>&nbsp;</td>
		<td><?php echo $paginator->sort('Name', 'name'); ?></td>
		<td><?php echo $paginator->sort('Unique ID', 'uuid'); ?></td>
		<td><?php echo $paginator->sort('Survey Type', 'SurveyType.type'); ?></td>
		<td><?php echo $paginator->sort('Created', 'created'); ?></td>
		<td><?php echo $paginator->sort('Modified', 'modified'); ?></td>
		<td>&nbsp;</td>
	</tr>
	<?php foreach ($surveys as $survey): ?>
		<tr>
			<td>
			<?php echo $html->link($html->image("icons/button_edit.png"),
			  array('controller'=>'surveys', 'action' => 'edit', 'id' => $survey['Survey']['id']),
			  array('escape' => false)); ?>&nbsp;
		  	<?php echo $html->link($html->image("icons/zoom.png"),
			  array('controller' => 'surveys', 'action' => 'view', 'id' => $survey['Survey']['id']),
			  array('escape' => false)); ?>&nbsp;
		  	<?php echo $html->link($html->image("icons/remove.png"),
			  array('action' => 'delete', 'id' => $survey['Survey']['id']), null,
			  'Are you sure you want to delete this survey?',
			  array('escape' => false)); ?>
			</td>
			<td><?php echo $survey['Survey']['name']; ?></td>
			<td><?php echo substr($survey['Survey']['uuid'],1,8); ?></td>
			<td><?php echo $survey['SurveyType']['type']; ?></td>
			<td><?php echo date("m/d/y g:i A", strtotime($survey['Survey']['created'])); ?></td>
			<td><?php echo date("m/d/y g:i A", strtotime($survey['Survey']['modified'])); ?></td>
			<td>
			<?php echo $html->link('Audience List',
			  array('controller' => 'surveys', 'action' => 'audience_list', 'id' => $survey['Survey']['id'])); ?>
		 	</td>
		</tr>
	<?php endforeach; ?>
		<tr>
			<!-- Pagination -->
			<td colspan="3">
				<!-- Shows the next and previous links -->
				<?php
					echo $paginator->prev('« Previous ', null, null, array('class' => 'disabledPageLink'));
					echo $paginator->next(' Next »', null, null, array('class' => 'disabledPageLink'));
				?>
				<br />
				<!-- prints X of Y, where X is current page and Y is number of pages -->
				<?php echo $paginator->counter(); ?>
			</td>
		</tr>
</table>
<?php } else { ?>
	<br /><br />
	<span class="errMsg">No surveys found</span>
<?php } ?>
<br /><br />